<template>
  <div class="app-container">
    <el-row :gutter="10">
      <!-- 清理系统数据 -->
      <el-col
        :xs="24"
        :sm="12"
        :md="12"
        :lg="8"
        :xl="6"
        v-has-perm="'admin:tool:clear_sys_deleted_data'"
      >
        <el-card class="mb-2">
          <template #header>
            <span class="font-600">{{
              $t(
                'menu.admin.tool.action.clear_sys_deleted_data',
                '清理删除数据',
              )
            }}</span>
          </template>
          <div
            class="block font-light .dark:text-gray-300 overflow-auto h-[100px]"
          >
            <span>
              {{
                $t(
                  'menu.admin.tool.desc.clear_sys_deleted_data',
                  '清理系统数据将删除所有已标记为删除的数据表内容，且无法恢复。',
                )
              }}
            </span>
          </div>
          <template #footer>
            <div class="width-[100%] flex justify-end">
              <el-button plain type="danger" @click="clearSysDeletedData">
                {{ $t('common.action.execute', '执行') }}
              </el-button>
            </div>
          </template>
        </el-card>
      </el-col>
      <!-- 清理系统日志 -->
      <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="6">
        <!-- v-has-perm="'admin:tool:clear_runtime_logs'" -->
        <el-card class="mb-2">
          <template #header>
            <span class="font-600">{{
              $t('menu.admin.tool.action.clear_runtime_logs', '清理运行时日志')
            }}</span>
          </template>
          <div
            class="block font-light .dark:text-gray-300 overflow-auto h-[100px]"
          >
            <span>
              {{
                $t(
                  'menu.admin.tool.desc.clear_runtime_logs',
                  '执行清理系统日志文件，将删除所有runtime目录下的所有日志文件，且无法恢复。',
                )
              }}
            </span>
          </div>
          <template #footer>
            <div class="width-[100%] flex justify-end">
              <el-button plain type="danger" @click="clearRuntimeLogs">
                {{ $t('common.action.execute', '执行') }}
              </el-button>
            </div>
          </template>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import ToolAPI from '@/api/admin/admin/tool';
import { useTools } from './useTools.js';
import { smartTranslate as $t, transPlaceholder as $p } from '@/lang';

// 清理系统软删除的数据
const { clearSysDeletedData, clearRuntimeLogs } = useTools(ToolAPI);

// 组件选项
defineOptions({
  name: 'AdminTool',
  inheritAttrs: false,
});
</script>

<style lang="scss" scoped></style>
